<template>
    <div id="personalCentre">
        <nav>
            <img v-bind:src="photoUrl" alt="我的头像">
                    <a :style="componentId==='personHome'? 'color:white;background-color:#ff0a60;':''" @click="componentId='personHome'">首页</a>
                    <a :style="componentId==='renter'? 'color:white;background-color:#ff0a60;':''" @click="componentId='renter'">合租伙伴</a>
                    <a :style="componentId==='myAttention'? 'color:white;background-color:#ff0a60;':''" @click="componentId='myAttention'">我的关注</a>
                    <a :style="componentId==='myRecord'? 'color:white;background-color:#ff0a60;':''" @click="componentId='myRecord'">看房记录</a>
                    <a :style="componentId==='myEntrust'? 'color:white;background-color:#ff0a60;':''" @click="componentId='myEntrust'">我的委托</a>
                    <a :style="componentId==='myInformation'? 'color:white;background-color:#ff0a60;':''" @click="componentId='myInformation'">编辑资料</a>
        </nav>
        <span id="container">
            <component :is="componentId"></component>
        </span>
    </div>
</template>

<script>
    import personHome from "../components/personal-centre-home"
    import renter from "../components/personal-centre-renter"
    import myAttention from "../components/personal-centre-attention"
    import myRecord from "../components/personal-centre-record"
    import myEntrust from "../components/personal-centre-entrust"
    import myInformation from "../components/personal-centre-information"

    export default {
        name: "personal-centre",
        data(){
            return{
                photoUrl:require("../assets/img/默认头像.png"),
                componentId:"personHome"
            }
        },
        components:{
            personHome,renter,myAttention,myEntrust,myInformation,myRecord
        },
        created(){
            if(document.cookie.indexOf('login_state=true') === -1){
                this.$router.go(-1);
            }
        }
    }
</script>

<style scoped>
    #personalCentre{
        width: 60%;
        margin: 0 auto;
        min-width: 1000px;
        display: flex;
    }
    #personalCentre nav{
        height: 500px;
        width: 170px;
        background-color: white;
        margin-top: 30px;
        border: 2px solid rgba(0,0,0,0.2);
        display: flex;
        flex-direction: column;
        align-items: center;
        flex-wrap: nowrap;
    }
    #personalCentre nav img{
        height: 80px;
        width: 80px;
        margin: 20px;
        border-radius: 100%;
    }
    #personalCentre nav a{
        width: 100%;
        height: 60px;
        line-height: 60px;
        color: black;
        text-align: center;
    }
    #personalCentre nav a:hover{
        color: white;
        font-size: 15px;
        background-color: #ff0a60;
        position: relative;
        bottom: 5px;
        left: 5px;
        transition: 0.5s ease;
        box-shadow: -5px 5px #ff659f;
    }
    #personalCentre nav  a:active{
        filter: opacity(50%);
    }
    #personalCentre nav  a:visited{

    }
    #personalCentre #container{
        margin: 30px 0 30px 40px;
        height: 600px;
        width: 80%;
        background-color: white;
        border: 2px solid rgba(0,0,0,0.2);
    }
</style>